package com.xj.edu.hotel.service.serviceImpl;

import com.xj.edu.hotel.domain.Hotel;
import com.xj.edu.hotel.mapper.HotelMapper;
import com.xj.edu.hotel.mapper.CollectMapper;
import com.xj.edu.hotel.service.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class HotelServiceImpl implements HotelService {

    @Autowired
    private HotelMapper hotelMapper;

    @Override
    public List<Hotel> findAllHotel() {
        return hotelMapper.selectAll();
    }

    @Override
    public int deleteHotel(String id) {
        return hotelMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Hotel findById(String id) {
        return hotelMapper.selectById(id);

    }

    @Override
    public int editHotel(Hotel hotel) {
        return hotelMapper.updateByPrimaryKeySelective(hotel);
    }

    @Override
    public int addHotel(Hotel hotel) {
        return hotelMapper.insert(hotel);
    }

    @Override
    public List<Hotel> hotelRoom(String cityId, String hotelId) {
        return hotelMapper.hotelRoom(cityId,hotelId);
    }
    @Override
    public List<Hotel> findAllHotelName(String cityId) {
        return hotelMapper.findAllCityName(cityId);
    }

    @Override
    public List<Hotel> findHotel() {
        return hotelMapper.findHotel();
    }

    @Override
    public List<Hotel> findhotelType() {
        return hotelMapper.findhotelType();
    }

    @Override
    public List<Hotel> hotelShow(String hotelType) {
        return hotelMapper.hotelShow(hotelType);
    }

    /**
     * 通过预定数量查找酒店
     * @return
     */
    @Override
    public List<Hotel> searchHotelByOrderCount() {
        return hotelMapper.searchHotelByOrderCount();
    }

    @Override
    public List<Hotel> searchHotelName(String hotelName) {
        return hotelMapper.searchHotelName(hotelName);
    }

    @Override
    public List<Hotel> priceSearch(BigDecimal minPrice,BigDecimal maxPrice){ return hotelMapper.priceSearch(minPrice,maxPrice);}


    @Override
    public List<Hotel> hotelView(String cityName){return hotelMapper.hotelView(cityName);}

    @Override
    public List<Hotel> findHotels() {
        return hotelMapper.findAllHotel();
    }

    /**
     *  按预定时间最新查找酒店
     */
    @Override
    public List<Hotel> searchHotelByOrderTime(Date date){ return hotelMapper.searchHotelByOrderTime(date);}
}
